﻿#ifndef RUNABLE_H
#define RUNABLE_H

#include <QThread>


class RunableBase : public QThread {
    Q_OBJECT
public:
    explicit RunableBase(QObject *parent = nullptr)
        : QThread(parent)
    {}

    virtual ~RunableBase() = default;

signals:
    void sendMsg(const QString &msg);
};

template <typename T>
class Runable : public RunableBase {
public:
    explicit Runable(QObject *parent = nullptr)
        : RunableBase(parent)
        , isRunning(true)
        , buffer(nullptr)
    {}
    virtual ~Runable() = default;

private:
    virtual void run() override = 0;

protected:
    bool isRunning;
    T *buffer;
};

#endif // RUNABLE_H
